package cn.tvplaza.shakeclub;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * @class description 登录界面
 */
public class LaunchActivity extends AppCompatActivity {

    @Bind(R.id.temptext)
    TextView tempTv;

    private Handler handler = new Handler();

    //
    private int timeCount = 1;
    private Runnable task = new Runnable() {
        public void run() {

            handler.postDelayed(this, 1000);
            if (timeCount > 0) {
                timeCount--;
                tempTv.setText("" + timeCount);
            } else {
                handler.removeCallbacks(task);
                startActivity(new Intent(LaunchActivity.this, MainActivity.class));
                finish();
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        requestWindowFeature(Window.FEATURE_NO_TITLE);
//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_launch);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        tempTv.setText("" + timeCount);
        handler.postDelayed(task, 1000);
    }
}
